package nc;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Qhw3 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        System.out.println(printNum(line));
    }

    private static int printNum(String digNum) {
        String nums = "0123456789ABCDEF";
        int num = 0;
        for (int i = 2; i < digNum.length(); i++) {
            char c = digNum.charAt(i);
            int i1 = nums.indexOf(c);
            num = num * 16 + i1;
        }
        return num;
    }


}
